package com.beiing.tianshuai.tianshuai.dongtai.model;

import com.beiing.tianshuai.tianshuai.dongtai.CallBack;
import com.beiing.tianshuai.tianshuai.entity.DynamicForwardBean;
import com.beiing.tianshuai.tianshuai.network.DataManager;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by magikliu on 2017/8/4.
 */

public class DynamicForwardModel implements DynamicForwardModelImpl {

    @Override
    public void pushMyForward(String form_uid, String to_uid, String r_id, String content, final CallBack callBack) {
        DisposableObserver<DynamicForwardBean> observer = new DisposableObserver<DynamicForwardBean>() {
            @Override
            public void onNext(@NonNull DynamicForwardBean dynamicForwardBean) {
                callBack.result(dynamicForwardBean);
            }

            @Override
            public void onError(@NonNull Throwable e) {
                callBack.error(e);
            }

            @Override
            public void onComplete() {

            }
        };
        DataManager.getForwardResult(form_uid, to_uid, r_id, content)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }
}
